﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WsusWebAdmin.Web.Helpers
{
    public class TreeNode<T>
    {
        public T NodeData { get; set; }
        public ICollection<TreeNode<T>> SubItems { get; private set; }

        public TreeNode(T nodeData):this()
        {
            NodeData = nodeData;
        }

        public TreeNode()
        {
            SubItems = new List<TreeNode<T>>();
        }

        public TreeNode<T> AddSubNode(TreeNode<T> treeNode)
        {
            SubItems.Add(treeNode);
            return treeNode;
        }

        public TreeNode<T> AddSubNode(T nodeData)
        {
            return AddSubNode(new TreeNode<T>(nodeData));
        }
    }
}